/*-------------------<-- Start of Description-->---------------------\ | Justify a macro text string; | |---------------------<-- End of Description-->----------------------| |--------------------------------------------------------------------| |------------<-- Start of Files or Arguments Needed-->---------------| | Arguments: | | string: A string or a quoted string will be needed; | | justify=center, centralized; | | right, right justified; | | left, left justified; | |---------------<-- End of Files Arguments Needed-->-----------------| |--------------------------------------------------------------------| |------------------<-- Start of Files Created-->---------------------| | Example: title "%justify(%initcaps(this is a text),justify=right)";| | Usage: %justify(string, justify=); | \-------------------<-- End of Files Created-->---------------------*/ %macro justify/parmbuff; /*--------------------------------------------\ | Copy Right: Duo Zhou; | | Created: 9-16-2001 10:12pm; | | Modified: 12-25-2001 3:01pm; | | Purpose: Justify a macro string; | \--------------------------------------------*/ %local _justifytexttxt1_ _justifytexttxt2_ _justifytext_ _justifyls_ _justifyindent_ _justifynewtext_ string justify; %let _justifyls_ = %SYSFUNC(GETOPTION(linesize)); %if (%length(%nrbquote(&syspbuff)) gt 2) %then %do; %let _justifytexttxt1_=%nrbquote(%sysfunc(compbl(%nrbquote(%substr(%nrbquote(&syspbuff), 2, %eval(%length(%nrbquote(&syspbuff))-2)))))); %if (%index(%nrbquote(%upcase(%sysfunc(compress(%nrbquote(&_justifytexttxt1_))))),%str(JUSTIFY=))) %then %do; %let _justifymethod_=%nrbquote(%qscan(%nrbquote(&_justifytexttxt1_), 2, %str(=))); %if (%index(%nrbquote(%upcase(%nrbquote(&_justifytexttxt1_))),%str( JUSTIFY))) %then %let _justifytexttxt1_=%nrbquote(%substr(%nrbquote(&_justifytexttxt1_), 1, %eval(%index(%nrbquote(%upcase(%nrbquote(&_justifytexttxt1_))),%str( JUSTIFY))-2))); %else %if (%index(%nrbquote(%upcase(%nrbquote(&_justifytexttxt1_))),%str(JUSTIFY))) %then %let _justifytexttxt1_=%nrbquote(%substr(%nrbquote(&_justifytexttxt1_), 1, %eval(%index(%nrbquote(%upcase(%nrbquote(&_justifytexttxt1_))),%str(JUSTIFY))-2))); %end; %else %if (%index(%nrbquote(%upcase(%nrbquote(%sysfunc(compress(%nrbquote(&_justifytexttxt1_)))))),%str(JUST=))) %then %do; %let _justifymethod_=%nrbquote(%qscan(%nrbquote(&_justifytexttxt1_), 2, %str(=))); %if (%index(%nrbquote(%upcase(%nrbquote(&_justifytexttxt1_))),%str( JUST))) %then %do; %let _justifytexttxt1_=%nrbquote(%substr(%nrbquote(&_justifytexttxt1_), 1, %eval(%index(%nrbquote(%upcase(%nrbquote(&_justifytexttxt1_))),%str( JUST))-2))); %put text is %nrbquote(&_justifytexttxt1_); %end; %else %if (%index(%nrbquote(%upcase(%nrbquote(&_justifytexttxt1_))),%str(JUST))) %then %let _justifytexttxt1_=%nrbquote(%substr(%nrbquote(&_justifytexttxt1_), 1, %eval(%index(%nrbquote(%upcase(%nrbquote(&_justifytexttxt1_))),%str(JUST))-2))); %end; %let _justifytexttxt2_=%nrbquote(%sysfunc(dequote(%nrbquote(&_justifytexttxt1_)))); %if (%index(%nrbquote(&_justifytexttxt1_),%nrbquote(&_justifytexttxt2_)) >1) %then %let _justifynumofspace_ = %EVAL(&_justifyls_ - %LENGTH(&_justifytexttxt2_)-2); %else %let _justifynumofspace_ = %EVAL(&_justifyls_ - %LENGTH(&_justifytexttxt1_)); %if (%quote(%upcase(&_justifymethod_))=CENTER or %quote(%upcase(&_justifymethod_))=C or %quote(%upcase(&_justifymethod_)) eq) %then %LET _justifyindent_ = %eval(&_justifynumofspace_/2);/*%put numofspace is &numofspace., indent is &indent.;*/ %else %if (%quote(%upcase(&_justifymethod_))=RIGHT or %quote(%upcase(&_justifymethod_))=R) %then %LET _justifyindent_ = %eval(&_justifynumofspace_-5); %else %let _justifyindent_=0; %let _justifynewtext_=; %if &_justifyindent_ >=1 %then %do; %do _i_=1 %to &_justifyindent_; %let _justifynewtext_=&_justifynewtext_%str( ); %end; %end; %if (%index(&_justifytexttxt1_,&_justifytexttxt2_) >1) %then %do; %if (%index(&_justifytexttxt2_,%str(%"))) %then %let _justifynewtext_=%nrbquote(%sysfunc(tranwrd(%nrbquote(&_justifytexttxt2_),%str(%"),%str(%')))); %let _justifynewtext_=&_justifynewtext_"%nrbquote(&_justifytexttxt2_)"; %end; %else %let _justifynewtext_=%nrbquote(&_justifynewtext_.&_justifytexttxt1_); %nrbquote(&_justifynewtext_) %end; %MEND justify;